using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace WindowsControlLibrary1
{
    public partial class ViewFiles : UserControl
    {
        public ViewFiles()
        {
            InitializeComponent();
        }

        private string strPath;

        public string Path
        {
            get { return strPath; }
            set { strPath = value; }
        }
        private void btnView_Click(object sender, EventArgs e)
        {
            ShowFile();
        }
        void ShowFile()
        {
            try
            {
                DirectoryInfo dir = new DirectoryInfo(strPath);
                lvData.Columns.Add("Name", 100, 0);
                lvData.Columns.Add("Size", 50, 0);
                lvData.Columns.Add("Date", 70, 0);
                lvData.View = View.Details;
                ListViewItem item1;

                foreach (FileInfo d in dir.GetFiles("*.*"))
                {

                    item1 = new ListViewItem(d.Name);
                    item1.SubItems.Add(d.Length.ToString());
                    item1.SubItems.Add(d.CreationTime.ToLongDateString());
                    lvData.Items.Add(item1);
                }
                label1.Text = strPath;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}